
package com.hx.portal.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.order.pojo.Item;
import com.hx.order.service.ItemService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/item")
@Api(description = "项目相关接口文档")
public class ItemController {

    @Reference
    private ItemService itemService;

    @GetMapping("/findAll")
    public List<Item> findAll(){
        return itemService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<Item> findPage(int page, int size){
        return itemService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Item> findList(@RequestBody Map<String,Object> searchMap){
        return itemService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Item> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  itemService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public Item findById(Long id){
        return itemService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody Item item){
        itemService.add(item);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody Item item){
        itemService.update(item);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        itemService.delete(id);
        return new Result();
    }

}
